﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Ams.Extensions
{
    public static class IEnumerableExtensions
    {
        public static void Each<T>(this IEnumerable<T> enumerable, Action<T> action)
        {
            using (var enumerator = enumerable.GetEnumerator())
            {
                while(enumerator.MoveNext())
                {
                    action(enumerator.Current);
                }
            }
        }

        public static bool None<T>(this IEnumerable<T> enumerable)
        {
            return !enumerable.Any();
        }
        public static bool None<T>(this IEnumerable<T> enumerable, Func<T, bool> predicate)
        {
            return !enumerable.Any(predicate);
        }
    }
}
